import os,sys
import pefile

def main(args):
	if not os.path.exists(args[1]):
		print >>sys.stderr, "Input file does not exist"

	pe = pefile.PE(args[1])
	pe.OPTIONAL_HEADER.Subsystem = 2
	pe.FILE_HEADER.TimeDateStamp = 0xfeedbab0
	pe.write(args[2])
	print "Patched successfully!"

def usage(selfName):
	print >>sys.stderr, "Usage: %s <input PE> <output PE>"%os.path.basename(selfName)

if '__main__' == __name__:
	if len(sys.argv) == 3:
		sys.exit(main(sys.argv))
	else:
		usage(sys.argv[0])
		sys.exit(1)